package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 *  博主关注前端控制器
 *
 * @author leizi
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Autowired
    private IFollowService followService;

    /**
     * 确认是否已经关注
     *
     * @param followId
     * @return
     */
    @GetMapping("/or/not/{followId}")
    public Result isFollow(@PathVariable Long followId) {
        return followService.isFollow(followId);
    }

    /**
     * 关注/取消关注
     *
     * @param followId 博主id
     * @param isFollow 是否关注 true：关注 false：取消关注
     * @return
     */
    @PutMapping("/{followId}/{isFollow}")
    public Result followUser(@PathVariable Long followId, @PathVariable boolean isFollow) {
        return followService.followUser(followId, isFollow);
    }

    /**
     * 共同关注
     *
     * @param userId 被访者用户id
     * @return
     */
    @GetMapping("/common/{userId}")
    public Result followCommon(@PathVariable Long userId) {
        return followService.followCommon(userId);
    }
}
